<template>
  <div>
    <div class="tag-wrapper flex">
      <div class="flex">
       <span class="w-60">语种:</span>
        <el-radio-group v-model="queryInfo.area">
          <el-radio v-for="item in artistListData.area" :key="item.id" :label="item.id">{{ item.value }}</el-radio>
        </el-radio-group>
      </div>
      <div class="flex">
        <span class="w-60">分类:</span>
        <el-radio-group v-model="queryInfo.type">
          <el-radio v-for="item in artistListData.type" :key="item.id" :label="item.id">{{ item.value }}</el-radio>
        </el-radio-group>
      </div>
      <div class="flex">
        <span class="w-60">筛选:</span>
        <el-radio-group v-model="queryInfo.initial">
          <el-radio v-for="item in artistListData.initial" :key="item.id" :label="item.id">{{ item.value }}</el-radio>
        </el-radio-group>
      </div>
    </div>
    <cover :imgList="singerList" @clickToDo="toSingerDetail" v-loading.fullscreen.lock="loading" element-loading-spinner="el-icon-loading"></cover>
  </div>
</template>

<script>
import artistListData from '@/data/artistListData.js'
import { getSingers } from '@/api/singer.js'
import cover from '@/components/CoverImg/cover.vue'
export default {
  data () {
    return {
      // 条件列表数据
      artistListData,
      // 歌手列表
      singerList: [],
      queryInfo: {
        limit: 30,
        offset: 0,
        area: -1,
        type: -1,
        initial: '-1'
      },
      loading: true
    }
  },
  components: {
    cover
  },
  created () {
    this.showSingers()
  },
  methods: {
    async showSingers () {
      this.loading = true
      const res = await getSingers(this.queryInfo)
      console.log(res)
      this.singerList = res.data.artists
      this.loading = false
    },
    // 跳转到歌手详情页
    toSingerDetail (id) {
      this.$router.push(`/artistDetail/${id}`)
    }
  },
  watch: {
    queryInfo: {
      deep: true,
      handler () {
        this.showSingers()
      }
    }
  }
}
</script>

<style lang="less" scoped>
.tag-wrapper {
  flex-direction: column;
  text-align: left;
  span {
    height: 30px;
    line-height: 30px;
  }
  .el-radio-group {
    width: 80%;
    .el-radio {
      width: 60px;
      height: 30px;
      line-height: 30px;
    }
  }
}
</style>
